<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
      xmlns:h="http://xmlns.jcp.org/jsf/html"
      xmlns:f="http://xmlns.jcp.org/jsf/core">

    <ui:composition template="/template.xhtml">
        <ui:define name="title">
            <h:outputText value="#{bundle.EditProductTitle}"></h:outputText>
        </ui:define>
        <ui:define name="body">
            <h:panelGroup id="messagePanel" layout="block">
                <h:messages errorStyle="color: red" infoStyle="color: green" layout="table"/>
            </h:panelGroup>
            <h:form>
                <h:panelGrid columns="2">                    
                    <h:outputLabel value="#{bundle.EditProductLabel_name}" for="name" />
                    <h:inputText id="name" value="#{productController.selected.name}" title="#{bundle.EditProductTitle_name}" required="true" requiredMessage="#{bundle.EditProductRequiredMessage_name}"/>
                    <h:outputLabel value="#{bundle.EditProductLabel_description}" for="description" />
                    <h:inputTextarea rows="4" cols="30" id="description" value="#{productController.selected.description}" title="#{bundle.EditProductTitle_description}" required="true" requiredMessage="#{bundle.EditProductRequiredMessage_description}"/>
                    <h:outputLabel value="#{bundle.EditProductLabel_price}" for="price" />
                    <h:inputText id="price" value="#{productController.selected.price}" title="#{bundle.EditProductTitle_price}" required="true" requiredMessage="#{bundle.EditProductRequiredMessage_price}"/>
                    <h:outputLabel value="#{bundle.EditProductLabel_stock}" for="stock" />
                    <h:inputText id="stock" value="#{productController.selected.stock}" title="#{bundle.EditProductTitle_stock}" required="true" requiredMessage="#{bundle.EditProductRequiredMessage_stock}"/>                    
                    <h:outputLabel value="#{bundle.EditProductLabel_image}" for="image" />
                    <h:inputText id="image" value="#{productController.selected.image}" title="#{bundle.EditProductTitle_image}" />
                    <h:outputLabel value="#{bundle.EditProductLabel_categoryId}" for="categoryId" />
                    <h:selectOneMenu id="categoryId" value="#{productController.selected.categoryId}" title="#{bundle.EditProductTitle_categoryId}" required="true" requiredMessage="#{bundle.EditProductRequiredMessage_categoryId}">
                        <f:selectItems value="#{categoryController.itemsAvailableSelectOne}"/>
                    </h:selectOneMenu>
                </h:panelGrid>
                <h:commandLink action="#{productController.update}" value="#{bundle.EditProductSaveLink}"/>
                <br />
                <br />
                <h:link outcome="View" value="#{bundle.EditProductViewLink}"/>
                <br />
                <h:commandLink action="#{productController.prepareList}" value="#{bundle.EditProductShowAllLink}" immediate="true"/>
                <br />
                <br />
                <h:link outcome="/index_old" value="#{bundle.EditProductIndexLink}" />
            </h:form>
        </ui:define>
    </ui:composition>

</html>
